<?php
require_once(t3lib_extMgm::extPath('topstip').'fpdf/fpdf.php');
define('FPDF_FONTPATH', t3lib_extMgm::extPath('topstip').'fpdf/font/');

class pdf_export extends FPDF {

	private $headerString;

	public function getHeaderString() {
		return $this->headerString;
	}
		
	public function setHeaderString($title) {
		$this->headerString = $title;
	}

	public function Header(){
		$this->Ln(12);
		// arial bold 15
		$this->SetFont('Arial','B',12);
		
		// title
		$this->MultiCell(300,2,$this->getHeaderString()."\n",0,'L');
		$this->Ln(6);
	}

	function Footer() {
		// position at 1.5 cm from bottom
		$this->SetY(-15);
		// arial italic 8
		$this->SetFont('Arial','I',8);
		// page number
		$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
	}

	function FancyTable($headerRow,$data){

		$this->SetFillColor(224,224,255);
	    $this->SetTextColor(0);
		$this->SetFont('Arial','B',8);
	    
		$width = 26;
		foreach($headerRow as $columnName){
			$columnName[0] = strtoupper($columnName[0]);
			$this->Cell($width,8,$columnName,0,0,'L',true);
		}
		$this->SetFont('');
		$this->SetFillColor(235,235,255);
		$this->Ln();
		$fill=false;
		foreach($data as $row){
			foreach($row as $val){
				$this->Cell($width,6,$val,0,0,'L',$fill);
			}
			$fill = !$fill;
			$this->Ln();
		}
	}

	function printRecords($data){

		$this->SetFillColor(224,224,255);
	  $this->SetTextColor(0);
		$this->SetFont('Arial','B',8);

		$this->SetFont('');
		$this->SetFillColor(235,235,255);
		foreach($data as $row){
			$this->Cell(50,6,array_shift($row). ', ' . array_shift($row),0,0,'L',true);
			$this->Cell(135,6,array_pop($row),0,0,'R',true);
			$this->Ln();
			foreach($row as $k => $v) {
				$this->Cell($width,5,$k . ': ' . $v,0,0,'L',false);
				$this->Ln();
			}
			$this->Ln();
		}
			

		
	}

}
?>